package edu.hgnc.beans;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class UserB implements BeanFactoryAware, ApplicationContextAware {
    private String username;
    private Integer age;

    private BeanFactory beanFactory;

    private ApplicationContext applicationContext;

    public BeanFactory getBeanFactory() {
        return beanFactory;
    }

    @Override
    public void setBeanFactory(BeanFactory beanFactory) {
        this.beanFactory = beanFactory;
    }

    public ApplicationContext getApplicationContext() {
        return applicationContext;
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) {
        this.applicationContext = applicationContext;
    }

    public void setUsername(String username) {
        System.out.println("2.setUsername注入属性值");
        this.username = username;
    }

    public void setAge(Integer age) {
        System.out.println("2.setAge注入属性值");
        this.age = age;
    }

    public UserB(){
        System.out.println("1.通过无参构造方法实例化");
    }

    public void initMethod(){
        System.out.println("3.初始化bean...");
    }

    public void destroyMethod(){
        System.out.println("5.销毁bean...");
    }

}
